<?php
		$activeStatusId = Rd_Request_Status::getActiveStatusId();
		$inactiveStatusId = Rd_Request_Status::getInactiveStatusId();
		$deniedStatusId = Rd_Request_Status::getDeniedStatusId();
		$request = $this->reserve->getRequest();
		switch($this->reserve->getStatusId()) {
			case $activeStatusId:
				$reserve_status_active = 'checked="CHECKED"';
				$reserve_status_inactive = '';
				$reserve_status_denied = '';
				$reserve_block_vis = '';
				break;
			case $inactiveStatusId:
				$reserve_status_active = '';
				$reserve_status_inactive = 'checked="CHECKED"';
				$reserve_status_denied = '';
				$reserve_block_vis = ' display:none;';
				break;
			case $deniedStatusId:
				$reserve_status_active = '';
				$reserve_status_inactive = '';
				$reserve_status_denied = 'checked="CHECKED"';
				$reserve_block_vis = ' display:none;';
				break;
			default :
				$reserve_status_active = '';
				$reserve_status_inactive = '';
				$reserve_status_denied = '';
				$reserve_block_vis = ' display:none;';
		}
		
		//dates
		$reserve_activation_date = $this->reserve->getActivationDate();
		$reserve_expiration_date = $this->reserve->getExpirationDate();
		
		//set reset dates to course dates
		$ci = new courseInstance($this->reserve->getCourseInstanceID());
		$course_activation_date = $ci->getActivationDate();	
		$course_expiration_date = $ci->getExpirationDate();

		//determine the parent heading
		$parent_heading_id = $this->reserve->getParent();		
		if(empty($parent_heading_id)) {
			$parent_heading_id = 'root';	//this will pre-select the main list
		}
?>
		<script language="JavaScript">
		//<!--			
			//shows/hides activation/expiration date form elements
			function toggleDates() {
				if(document.getElementById('reserve_status_active').checked) {
					document.getElementById('reserve_dates_block').style.display = '';
				}
				else {
					document.getElementById('reserve_dates_block').style.display = 'none';
				}
			}
			
			//resets reserve dates
			function resetDates(from, to) {
				document.getElementById('reserve_activation_date').value = from;
				document.getElementById('reserve_expiration_date').value = to;
			}
		//-->
		</script>
		
		<div class="headingCell1">RESERVE DETAILS</div>
		<div id="reserve_details" style="padding:8px 8px 12px 8px;">
<?php	
		$item = $this->reserve->getItem();
		//if($reserve->getStatusId() == 'DENIED ALL'){ 
		if ($item->getStatus() == Rd_Item::DENIED_STATUS) {
?>	
			<div>
				<strong>Current Status:</strong>&nbsp;<span class="copyright_denied">Item Access Denied</span>
				<br />
				Access to this item has be denied for All Classes.  The item must be reactivated before making changes. 
				<input type="hidden" name="reserve_status" value="<?php print($this->reserve->getStatusId()); ?>"/>
			</div>
<?php } else { ?>
	<?php	if (
				$this->reserve->getStatusId() != $deniedStatusId
				|| Account_Rd::atLeastStaff()
			){ ?>				
		<?php	if($this->reserve->isInProcess() && $request && $request->isInstantiated()){ ?>
				<div>
					<strong>Current Status:</strong>&nbsp;<span class="inProcess"><?php print($this->reserve->getStatusLabel()); ?></span>
					<?php if (Account_Rd::atLeastStaff()) { ?>
					<p>This item is currently being processed. Changes to status must be done in the <a href="./?cmd=displayRequest">Processing Queue.</a></p> 
					<?php  } else { ?>
					<p>This item is currently being processed. Please contact your Reserves staff to inquire about the status of this reserve.</p>
					<?php } ?>
					<input type="hidden" name="reserve_status" value="<?php print($this->reserve->getStatusId()); ?>" />
				</div>		
		<?php }	else if (Account_Rd::atLeastStaff()) { 
				if ($this->reserve->isInProcess()) {
			?>
				<div class="warning">This reserve's status (<?php print($this->reserve->getStatusLabel()); ?>) indicates that it is being processed, but it has no associated request.</div>
			<?php } ?>
				<div style="float:left; width:30%;">
					<strong>Reserve Status:</strong>
					<br />

					<div style="margin-left:10px; padding:3px;">
						<input type="radio" name="reserve_status" id="reserve_status_active" value="<?php print($activeStatusId);?>" onChange="toggleDates();" <?php print($reserve_status_active); ?> />&nbsp;<span class="active">ACTIVE</span>
						<input type="radio" name="reserve_status" id="reserve_status_inactive" value="<?php print($inactiveStatusId);?>" onChange="toggleDates();" <?php print($reserve_status_inactive); ?> />&nbsp;<span class="inactive">INACTIVE</span>					
					<?php 		
					if ($this->reserve->isInProcess()) {
						?>
						<br/><input type="radio" name="reserve_status" id="reserve_status_inprocess" value="<?php print($this->reserve->getStatusId());?>"  onChange="toggleDates();" checked="checked" />&nbsp;<span>leave as "<?php print($this->reserve->getStatusLabel());?></span>					
						<?php 
					} ?>
			<?php	if (Account_Rd::atLeastStaff()){ ?>
						<br/><input type="radio" name="reserve_status" id="reserve_status_denied" value="<?php print( $deniedStatusId);?>" onChange="toggleDates();" <?php print($reserve_status_denied); ?> />&nbsp;<span class="copyright_denied">DENY ACCESS FOR THIS CLASS ONLY</span>
			<?php 	} ?>
					</div>
				</div>
		<?php } ?>
				
							
				<div id="reserve_dates_block" style="float:left;<?php print($reserve_block_vis); ?>">
					<strong>Active Dates</strong> (YYYY-MM-DD) &nbsp;&nbsp; [<a href="#" name="reset_dates" onclick="resetDates('<?php print($course_activation_date); ?>', '<?php print($course_expiration_date); ?>'); return false;">Reset dates</a>]
					<br />
					<div style="margin-left:10px;">
						From:&nbsp;<input type="text" id="reserve_activation_date" name="reserve_activation_date" size="10" maxlength="10" value="<?php print($reserve_activation_date); ?>" /> <?php print($this->calendar->getWidgetAndTrigger('reserve_activation_date', $reserve_activation_date)); ?>
						To:&nbsp;<input type="text" id="reserve_expiration_date" name="reserve_expiration_date" size="10" maxlength="10" value="<?php print($reserve_expiration_date);?>" />  <?php print($this->calendar->getWidgetAndTrigger('reserve_expiration_date', $reserve_expiration_date)); ?>
					</div>
				</div>
							
				<div class="clearing">
					<strong>Current Heading:</strong> 
					<?php $this->getDisplayer()->displayHeadingSelect($ci, $parent_heading_id); ?>
				</div>		
	<?php	}  ?>
<?php	} ?>
		<div class="clear"></div>
	</div>